from configparser import ConfigParser
import os

class ReadIni:
    def __init__(self):
        # 获取项目路径
        self.base_path = os.path.dirname(os.getcwd())
        # print(self.base_path)
        # 实例化读取ini文件的类
        self.config = ConfigParser()
        # 获取path.ini文件完整路径
        pathini_path = os.path.join(self.base_path, "data\path.ini")
        # 进行文件读取
        with open(pathini_path, encoding="utf-8") as fp:
            self.config.read_file(fp)

    def get_excel_path(self):
        """
         # 读取excel完整路径
        :return:
        """
        relative_path = self.config.get("path", "excel_path")
        return os.path.join(self.base_path, relative_path)

    def get_params_path(self):
        """
        # 读取params.json完整路径
        :return:
        """
        relative_path = self.config.get("path", "params_path")
        return os.path.join(self.base_path, relative_path)

    def get_acountinfo_path(self):
        """
        #读取acountinfo.ini完整路径
        :return:
        """
        relative_path = self.config.get("path", "acountinfo_path")
        return os.path.join(self.base_path, relative_path)

    def get_yaml_path(self):
        """
        #读取sql.yaml完整路径
        :return:
        """
        relative_path = self.config.get("path", "yaml_path")
        return os.path.join(self.base_path, relative_path)

    def get_sheet_name(self):
        """
         # 获取sheet名称
        :return:
        """
        return self.config.get("path", "sheet_name")

    def get_testcase_path(self):
        """
        # 获取用例文件
        :return:
        """
        relative_path = self.config.get("path", "testcase_path")
        return os.path.join(self.base_path, relative_path)



if __name__ == "__main__":
    print(ReadIni().get_excel_path())
    print(ReadIni().get_params_path())
    print(ReadIni().get_acountinfo_path())
    print(ReadIni().get_sheet_name())
    print(ReadIni().get_yaml_path())
    print(ReadIni().get_testcase_path())